package com.easy.modules.sysmgr.web.action;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.easy.common.util.Const;
import com.easy.common.web.BaseController;
import com.easy.common.web.page.Msg;
import com.easy.modules.sysmgr.service.CompanyServiceI;
import com.easy.modules.sysmgr.web.form.CompanyForm;

@Controller
@RequestMapping("/sysmgr/company")
public class CompanyAction extends BaseController {
	
	@Autowired
	private CompanyServiceI companyService ;
	
	@RequestMapping("/company_main.do")
	public String company_main() throws Exception {
		return Const.SYSMGR + "orginfo_main" ;
	}
	
	@RequestMapping("/company_form.do")
	public String company_form(CompanyForm form, HttpServletRequest request) throws Exception {
		if(null != form.getId() && !"".equals(form.getId())) {
			request.setAttribute("id", form.getId()) ;
		}
		return Const.SYSMGR + "company_form" ;
	}
	
	@RequestMapping("/get.do")
	@ResponseBody
	public CompanyForm get(CompanyForm form, HttpServletRequest request) throws Exception {
		return this.companyService.get(form.getId()) ;
	}
	
	@RequestMapping("/doNotNeedAuth_get.do")
	@ResponseBody
	public CompanyForm doNotNeedAuth_get(CompanyForm form, HttpServletRequest request) throws Exception {
		return this.companyService.get(form.getId()) ;
	}
	
	@RequestMapping("/add.do")
	@ResponseBody
	public Msg add(CompanyForm form) throws Exception {
		return this.companyService.save(form) ;
	}
	
	@RequestMapping("/edit.do")
	@ResponseBody
	public Msg edit(CompanyForm form) throws Exception {
		return this.companyService.edit(form) ;
	}
	
	@RequestMapping("/delete.do")
	@ResponseBody
	public Msg delete(String id) throws Exception {
		return this.companyService.delete(id) ;
	}
	
	@RequestMapping("/tree.do")
	@ResponseBody
	public List<CompanyForm> treegrid(CompanyForm form ,String mode) throws Exception {
		return this.companyService.tree(form) ;
	}
	
	@RequestMapping("/doNotNeedAuth_tree.do")
	@ResponseBody
	public List<CompanyForm> treebox(CompanyForm form ,String mode) throws Exception {
		return this.companyService.tree(form) ;
	}
	
	@RequestMapping("/doNotNeedAuth_totalMember.do")
	@ResponseBody
	public Map<String, Object> totalMember(CompanyForm form) throws Exception {
		return this.companyService.totalMemberNum(form) ;
	}

}
